package com.api.gbhg.xxd.dao;

import weaver.conn.RecordSet;

public class GeneralDao {

    /**
     * 根据workflow_currentoperator表的requestId查找报销流程id
     *
     * @param requestId
     * @return
     */
    public static String getRequestIdDao(String requestId) {
        String sql = "select * from workflow_requestbase where requestid = " + requestId + " ";
        RecordSet rs = new RecordSet();
        rs.executeQuery(sql);
        rs.next();
        return rs.getString("workflowid");
    }

    /**
     * 根据流程id获取流程数据表名称
     *
     * @param workflowId
     * @return
     */
    public String getTableNameByWorkFlowId(String workflowId) {
        String sql = "SELECT f.TABLENAME FROM workflow_bill f WHERE f.ID=(SELECT b.FORMID FROM workflow_base b WHERE b.id=" + workflowId + ")";
        RecordSet recordSet = new RecordSet();
        recordSet.executeQuery(sql);
        recordSet.next();
        return recordSet.getString("TABLENAME");
    }

    /**
     * 根据requestid获取对应流程表id
     * @param table
     * @param requestId
     * @return
     */
    public String getBillidByRequestid(String table,String requestId){
        String sql = "select id from "+table+" where requestid = " + requestId + " ";
        RecordSet rs = new RecordSet();
        rs.executeQuery(sql);
        rs.next();
        return rs.getString("id");
    }


}
